package com.stoos.test;

import java.nio.charset.Charset;
import java.util.Base64;

public class Base64Util {
    final static Base64.Decoder decoder = Base64.getDecoder();
    final static Base64.Encoder encoder = Base64.getEncoder();

    public static String encoder(String decodertext, Charset charset){
        return encoder.encodeToString(decodertext.getBytes(charset));
    }

    public static String decoder(String encodedText, Charset charset){
        return new String(decoder.decode(encodedText),charset);
    }

    public static byte[] decoder(String encodedText){
        return decoder.decode(encodedText);
    }

    public static String encoderByte(byte[] decodertext){
        return encoder.encodeToString(decodertext);
    }
}
